package de.hska.bestellverwaltung.rest;

import java.util.Date;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import de.hska.util.Xlink;

@XmlRootElement(name="bestellung")
public class BestellungData {
	@XmlAttribute(name="id", required=true)
	public long id = Long.MIN_VALUE;
	
	public Date zeitstempel;
	
	@XmlElement(name="kunde", required=true)
	public Xlink kundeRef;
	
	public BestellungData() {
		super();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (id ^ (id >>> 32));
		result = prime * result
				+ ((zeitstempel == null) ? 0 : zeitstempel.hashCode());
		return result;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final BestellungData other = (BestellungData) obj;
		if (id != other.id)
			return false;
		if (zeitstempel == null) {
			if (other.zeitstempel != null)
				return false;
		} else if (!zeitstempel.equals(other.zeitstempel))
			return false;
		return true;
	}
	
	@Override
	public String toString() {
		return "{id=" + id + ", zeitstempel=" + zeitstempel + ", kunde=" + kundeRef.href + "}";
	}
}